home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
dnalib59.arj
/
EXTABS.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-12-28
|
2KB
|
49 lines
SUB ExpandTabs(Msg$)PUBLIC
CrLf$ = CHR$(13) + CHR$(10)
Msg$ = REMOVE$(msg$,CHR$(10)) 'Temporary remove line feeds from
Temp$ = "" 'string. Leave C/R's for INSTR.
DO 'Set the master loop
IF Msg$ = "" THEN EXIT LOOP 'If no more string to process,
'perform a grand exit
EndOfLine% = INSTR(Msg$,CHR$(13)) 'Find a C/R in the string.
IF EndOfLine% = 0 THEN 'If no C/R in string, reassign entire
Te$ = Msg$ 'remaining string to be processed
Msg$ = "" 'and null out the main string
ELSE
Te$ = LEFT$(Msg$,EndOfLine%) 'Other wise, strip off the left hand
Tm$ = RIGHT$(Msg$,LEN(Msg$) - EndOfLine%) 'portion of the string for processing
Msg$ = Tm$ 'and rid it from the main string.
Tm$ = ""
END IF
Te$ = REMOVE$(Te$,CHR$(13)) 'Remove the C/R from string.
DO
T1$ = "": T2$ = ""
TabPointer% = INSTR(Te$,CHR$(9)) 'Find a TAB in the sub-string
IF TabPointer% = 0 THEN EXIT LOOP 'If none present, whole line done.
T1$ = LEFT$(Te$,TabPointer% - 1) 'Split the process string into 2
T2$ = RIGHT$(Te$,LEN(Te$) - TabPointer%) 'sub-strings with TAB as delimiter.
'NOTE: (p) points to the TAB character
'in t1$ so use p-1 to avoid it.
T1$ = T1$ + " " 'Add a space to replace the lost TAB
DO UNTIL LEN(T1$) / 8 = INT(LEN(T1$) / 8) 'Lengthen to a multiple of 8
T1$ = T1$ + " "
LOOP
Te$ = T1$ + T2$ 'Concanotate original string with the
LOOP 'added spaces & loop for more TAB's
Temp$ = Temp$ + Te$ + CrLf$ 'Build temporary holding string
LOOP 'and loop back for next line.
Msg$ = Temp$ 'Reassign the temporary hold string to
'the string being called
Temp$ = "" 'and null out temp strings for memory
T1$ = "" 'management.
T2$ = ""
Te$ = "" 'finished
END SUB